snail.go: 檢查是否在圖片上
func (s *Snail) IsOnClick(mouseX, mouseY int) bool {
return s.PosX <= mouseX && mouseX <= s.PosX+40 && s.PosY <= mouseY && mouseY <= s.PosY+40
}
app.go: 取得滑鼠座標
func (g *App) Update() error {
mx, my := ebiten.CursorPosition()
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButton0) {
if g.snail.IsOnClick(mx, my) {
g.canPrompt = !g.canPrompt
}
}
// ...略
if g.canPrompt {
// 執行可以輸入
}
}